﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace lcmyjobs.Web.users
{
    public partial class UpdatePwd : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                this.Title = string.Format("个人管理中心—安全保密设置：更改密码    {0}", Application["webname"].ToString());
                if (Session["user_id"] != null)
                {
                    int id = int.Parse(Session["user_id"].ToString());
                    this.lblName.Text = Session["user_name"].ToString();

                }
                else
                {
                    Response.Redirect("userlogin.html");
                }
            }

        }

        protected void btnOK_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {

                if (Session["user_id"] != null)
                {
                    int id = int.Parse(Session["user_id"].ToString());
                    string oldpwd = txtname.Text;
                    string newpwd = txtpwd.Text;
                    //string strPwdMd5 = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(newpwd, "MD5").ToLower().Substring(8, 16);
                    lcmyjobs.BLL.user_basic bub = new BLL.user_basic();
                    oldpwd = myPublic.GetMd5(oldpwd);
                    newpwd = myPublic.GetMd5(newpwd);
                    int i = bub.UpdatePwd(id, oldpwd, newpwd);
                    if (i == 1)
                    {
                        Maticsoft.Common.MessageBox.Show(this, "修改成功！");
                    }
                    else
                    {
                        Maticsoft.Common.MessageBox.Show(this, "修改失败！");
                    }
                }
                else
                {
                    Response.Redirect("userlogin.html");
                }


            }
        }
    }
}